package com.lonni.rpc.core.serialize;

import java.io.Serializable;
import java.util.HashMap;

/**
 * 获取序列化方式
 * @author: Lonni
 * @date: 2024/6/27 0027 11:44
 */
public class SerializeFactory implements Serializable {
    private final static HashMap<String, IRpcSerialize> serializeHashMap = new HashMap<>();

    static {
        serializeHashMap.put("1", new KryoSerialize());
        serializeHashMap.put("2", new HessianSerialize());
        serializeHashMap.put("3", new FastJsonSerialize());
    }

    public static IRpcSerialize getSerialize(String type) {
        return serializeHashMap.getOrDefault(type, null);
    }

    public static void putSerialize(String type, IRpcSerialize serialize) {
        serializeHashMap.putIfAbsent(type, serialize);
    }


}



